package com.graducationdesign.springboot.controller.Admin;

import com.graducationdesign.springboot.entities.Administrator.GraducationDesignListMoudle.GraducationDesign;
import com.graducationdesign.springboot.mapper.GraducationDesignMapper;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.List;
import java.util.Map;

/**
 * @author Mr.zhneg
 * @create 2019-11-23-20:59
 */
@Controller
public class GraducationDesignListController {

//    这LoggerFactory是一个实用程序类，用于为各种日志记录API生成Logger，尤其是对于log4j，logback和JDK 1.4日志记录
    org.slf4j.Logger logger=  LoggerFactory.getLogger(getClass());

    @Autowired
    GraducationDesignMapper graducationDesignMapper;
    //查看毕设命题管理界面，并且可以查询毕设题目
    @GetMapping("/graducationdesign")
    public String list(GraducationDesign graducationDesign, Map<String,Object> map){

        logger.info("毕设命题查询。。。"+graducationDesign);
       List<GraducationDesign> graducationDesigns= graducationDesignMapper.getGraducationDesign(graducationDesign);
       logger.info("查询操作：毕设命题查询结果。。。"+graducationDesigns);
       map.put("graducationDesign",graducationDesigns);
       map.put("graducationDesignList",graducationDesign.getGraducationDesignList());
        return "Administrator/graduationDesignInformationMoudle/graducationdesignlist";
    }

    //查看毕设命题信息
    @GetMapping("/graducationdesigns/{id}")
    public String view(@PathVariable("id") Integer id,Map<String,Object> map){

        logger.info("查询操作：查询毕设命题编码为"+id+"的命题信息");
        GraducationDesign graducationDesign=graducationDesignMapper.getGraducationDesignById(id);
        map.put("graducationDesigns",graducationDesign);
        return "Administrator/graduationDesignInformationMoudle/graducationdesignview";
    }

    //删除毕业设计命题
    @DeleteMapping("/graducationdesigns/{id}")
    public String delete(@PathVariable("id") Integer id){

        logger.info("删除操作：删除编号为"+id+"毕设命题");
        graducationDesignMapper.deleteStudentById(id);
//        return "Administrator/graduationDesignInformationMoudle/graducationdesignlist";
        return "redirect:/graducationdesign";
    }
}
